package com.example.aiquestions.mapper;

import com.example.aiquestions.entity.*;
import com.example.aiquestions.model.dto.QuestionDetail;
import com.example.aiquestions.model.dto.QuestionResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface QuestionMapper {
    int insertQuestion(Question question);
    
    int insertOption(QuestionOption option);
    
    int insertMultipleChoiceAnswer(MultipleChoiceAnswer answer);
    
    int insertKeyPoint(AnswerKeyPoint keyPoint);
    
    int insertTag(@Param("questionId") Long questionId, @Param("tag") String tag);
    
    int insertKnowledgePoint(@Param("questionId") Long questionId, @Param("knowledgePoint") String knowledgePoint);
    
    Question getQuestionById(@Param("id") Long id);
    
    List<QuestionResponse.QuestionData.SubQuestion> getSubQuestions(@Param("parentId") Long parentId);

    // 根据ID获取题目的完整信息
    QuestionDetail getQuestionWithDetailsById(@Param("id") Long id);
    
    // 根据ID列表批量获取题目的完整信息
    List<QuestionDetail> getQuestionsByIds(@Param("ids") List<Long> ids);

    /**
     * 删除题目基本信息
     */
    int deleteQuestionById(@Param("id") Long id);

    /**
     * 删除题目的所有选项
     */
    int deleteQuestionOptions(@Param("questionId") Long questionId);

    /**
     * 删除题目的多选题答案
     */
    int deleteMultipleChoiceAnswers(@Param("questionId") Long questionId);

    /**
     * 删除题目的答案要点
     */
    int deleteKeyPoints(@Param("questionId") Long questionId);

    /**
     * 删除题目的标签
     */
    int deleteTags(@Param("questionId") Long questionId);

    /**
     * 删除题目的知识点
     */
    int deleteKnowledgePoints(@Param("questionId") Long questionId);

    /**
     * 更新题目基本信息
     */
    int updateQuestion(Question question);

    /**
     * 获取阅读理解题的所有子题目ID
     */
    List<Long> getSubQuestionIds(@Param("parentId") Long parentId);
} 